package cn.diancan.action.api;

import cn.diancan.action.BaseAction;
import cn.diancan.vo.MealLocationApiActionVo;
import cn.diancan.vo.MealLocationVo;
import com.opensymphony.xwork2.ModelDriven;

import java.util.List;

/**
 * @author Sky
 */
public class MealLocationAction extends BaseAction implements ModelDriven<MealLocationApiActionVo>{

    private MealLocationApiActionVo requestVo = new MealLocationApiActionVo();


    public String mealLocations(){
        try {
            List<MealLocationVo> mealLocationVoList = mealLocationService.findMealLocationVoList(1, 100);
            return jsonFormat(mealLocationVoList);
        } catch (Exception e) {
            return jsonError(e);
        }
    }

    public String singleMealLocation(){
        try {
            MealLocationVo mealLocation = mealLocationService.findVobyMealLocationId(requestVo.getMealLocationId());
            return jsonFormat(mealLocation);
        } catch (Exception e) {
            return jsonError(e);
        }
    }

    @Override
    public MealLocationApiActionVo getModel() {
        return requestVo;
    }
}
